﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SortMenu.aspx.cs" Inherits="Manager_Menu_SortMenu" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <link href="../../Pub/Css/AdminStyles.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    body 
    {
		    background-color:WhiteSmoke;
		    font-family:Tahoma;
		    font-size:13px;
    }  
   
    
    .None_UnderlineLink
    {
	    text-decoration: none;
    }
    .td_Label
    {
	    background-color:#99ffff
    }

    </style>
</head>
<body style="background-color:#ccffff">
    <form id="form1" runat="server">
 <div align="center">
				<table style="BORDER-COLLAPSE: collapse;" cellspacing="0" cellpadding="2"
									 border="0">
					<tr>

						<td  width="70%" valign="top" align="left">							
                            <asp:ListBox ID="lbPortalAp_seq"   runat="server" Height="450px" Width="600px"></asp:ListBox></td>
						<td width="30%" valign="middle">					
							&nbsp;<img src="../../Images/Icon/SortDesc.gif"   onclick="Down()" alt ="" style="CURSOR:hand"/>
							<img src="../../Images/Icon/SortAsc.gif" alt =""  onclick="Up()" style="CURSOR:hand"/>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center" style="height: 15px">
                            <input id="btnClose" class="cssButton" style="width: 74px" type="button" value="OK" onclick="fncOK()" />&nbsp;</td>
					</tr>
				</table>
			</div>
    </form>
</body>
		<script language="javascript" type ="text/javascript" >
		function fncOK()
		{
		    window.opener.fnOK();
		    window.close();
		}
			
			function Up()
			{		
				var lbPortalAp_seq=document.getElementById("lbPortalAp_seq");
				var index=lbPortalAp_seq.selectedIndex;	
				if(lbPortalAp_seq.selectedIndex==-1)	
				    alert('Chọn Menu')		;
				else if(lbPortalAp_seq.selectedIndex==0)
				    alert('Đã ở đầu');
				else
				{
				    // alert(lbPortalAp_seq.selectedIndex);
				   var ID1=lbPortalAp_seq.options[lbPortalAp_seq.selectedIndex].value;
				    var temp;				   
				    temp=lbPortalAp_seq.item(index).value;
				    lbPortalAp_seq.item(index).value =lbPortalAp_seq.item(index-1).value;
				    lbPortalAp_seq.item(index-1).value=temp;
				    				    				    				   				    
				    var mylbPortalAp_seq = lbPortalAp_seq.item(index).text.split("/ ");
				    var mylbPortalAp_seq1 = lbPortalAp_seq.item(index-1).text.split("/ ");
				    lbPortalAp_seq.item(index).text =(index+1)+'/ '+mylbPortalAp_seq1[1];
				    lbPortalAp_seq.item(index-1).text=(index)+'/ '+mylbPortalAp_seq[1];
				    
				    var ID2=lbPortalAp_seq.options[lbPortalAp_seq.selectedIndex].value;
					Manager_Menu_SortMenu.UpdTurnSort(ID1,ID2,UpdTurnSort_Callback);
					lbPortalAp_seq.selectedIndex=index-1;
				}
				
			}
			
			function Down()
			{   
				var lbPortalAp_seq=document.getElementById("lbPortalAp_seq");
				var index=lbPortalAp_seq.selectedIndex;	
				if(lbPortalAp_seq.selectedIndex==-1)	
				    alert('Chọn Server')		;
				else if(lbPortalAp_seq.selectedIndex>=lbPortalAp_seq.length-1)
				    alert('Đã ở cuối');
				else
				{
				    // alert(lbPortalAp_seq.selectedIndex);
				    var ID1=lbPortalAp_seq.options[lbPortalAp_seq.selectedIndex].value;
			        var ID2=lbPortalAp_seq.options[lbPortalAp_seq.selectedIndex+1].value;

			        var temp;				    				
			        temp=lbPortalAp_seq.item(index).value;
				    lbPortalAp_seq.item(index).value =lbPortalAp_seq.item(index+1).value;
				    lbPortalAp_seq.item(index+1).value=temp;
				    		    				    				   				    
				    var mylbPortalAp_seq = lbPortalAp_seq.item(index).text.split("/ ");
				    var mylbPortalAp_seq1 = lbPortalAp_seq.item(index+1).text.split("/ ");
				    lbPortalAp_seq.item(index).text =(index+1)+'/ '+mylbPortalAp_seq1[1];
				    lbPortalAp_seq.item(index+1).text=(index+2)+'/ '+mylbPortalAp_seq[1];			    
		
					Manager_Menu_SortMenu.UpdTurnSort(ID1,ID2,UpdTurnSort_Callback);
					lbPortalAp_seq.selectedIndex=index+1;
				}							
			}			
			function UpdTurnSort_Callback(res)
			{
			    

			}
		
			
			
        </script>
</html>